package com.qianli.cashmama.trade.client.trade.request;

import com.fqgj.common.api.ParamsObject;
import com.fqgj.exception.common.ApplicationException;
import com.qianli.cashmama.trade.client.vo.DiscountListVO;
import com.qianli.cashmama.trade.common.enums.TradeClientTypeEnum;
import com.qianli.cashmama.trade.common.enums.TradeTypeEnum;
import com.qianli.cashmama.trade.common.enums.UsageOfLoanEnum;
import org.apache.commons.lang.StringUtils;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/7/20
 * Time: 下午2:32
 */

public class CreateTradeRequest extends ParamsObject {

    private static final long serialVersionUID = -6840288880079433834L;

    /**
     * 产品
     */
    private String productCode;
    /**
     * 用户code
     */
    private String userCode;
    /**
     * 渠道code
     */
    private String channelCode;

    /**
     * 商户号
     */
    private String merchantCode;

    /**
     *
     */
    private String productCategory;

    /**
     * 优惠列表
     */
    private List<DiscountListVO> discountList;

    /**
     * 客户端类型  1:安卓  2:IOS 3:H_5
     */
    private TradeClientTypeEnum clientType;

    /**
     * app code  : SDZZ , QSYQ
     */
    private String appCode;

    /**
     * 借款用途  0:个人日常消费，1:装修，2：旅游，3:教育，4:医疗，5:其他(预留)
     */
    private UsageOfLoanEnum usageOfLoan;

    /**
     * 交易类型  0:内部订单(默认)
     */
    private TradeTypeEnum tradeType;

    /**
     * 附加参数信息
     */
    private String extraData;

    /**
     * 附加信息【用户下单时信息包括设备信息等】
     */
    private TradeExtraData tradeExtraData;

    @Override
    public void validate() {
        if (StringUtils.isEmpty(productCategory)
                || StringUtils.isEmpty(productCode)
                || StringUtils.isEmpty(userCode)
                || StringUtils.isEmpty(channelCode)
                || clientType == null
        ) {
            throw new ApplicationException("Parameter error");
        }
    }

    public TradeExtraData getTradeExtraData() {
        return tradeExtraData;
    }

    public CreateTradeRequest setTradeExtraData(TradeExtraData tradeExtraData) {
        this.tradeExtraData = tradeExtraData;
        return this;
    }

    public String getExtraData() {
        return extraData;
    }

    public CreateTradeRequest setExtraData(String extraData) {
        this.extraData = extraData;
        return this;
    }

    public UsageOfLoanEnum getUsageOfLoan() {
        return usageOfLoan;
    }

    public CreateTradeRequest setUsageOfLoan(UsageOfLoanEnum usageOfLoan) {
        this.usageOfLoan = usageOfLoan;
        return this;
    }

    public TradeTypeEnum getTradeType() {
        return tradeType;
    }

    public CreateTradeRequest setTradeType(TradeTypeEnum tradeType) {
        this.tradeType = tradeType;
        return this;
    }

    public String getAppCode() {
        return appCode;
    }

    public CreateTradeRequest setAppCode(String appCode) {
        this.appCode = appCode;
        return this;
    }

    public TradeClientTypeEnum getClientType() {
        return clientType;
    }

    public CreateTradeRequest setClientType(TradeClientTypeEnum clientType) {
        this.clientType = clientType;
        return this;
    }

    public List<DiscountListVO> getDiscountList() {
        return discountList;
    }

    public CreateTradeRequest setDiscountList(List<DiscountListVO> discountList) {
        this.discountList = discountList;
        return this;
    }

    public String getProductCode() {
        return productCode;
    }

    public CreateTradeRequest setProductCode(String productCode) {
        this.productCode = productCode;
        return this;
    }

    public String getUserCode() {
        return userCode;
    }

    public CreateTradeRequest setUserCode(String userCode) {
        this.userCode = userCode;
        return this;
    }

    public String getChannelCode() {
        return channelCode;
    }

    public CreateTradeRequest setChannelCode(String channelCode) {
        this.channelCode = channelCode;
        return this;
    }

    public String getProductCategory() {
        return productCategory;
    }

    public CreateTradeRequest setProductCategory(String productCategory) {
        this.productCategory = productCategory;
        return this;
    }

    public String getMerchantCode() {
        return merchantCode;
    }

    public CreateTradeRequest setMerchantCode(String merchantCode) {
        this.merchantCode = merchantCode;
        return this;
    }
}
